import Vue from '@/main.js';






export  function getSupplierData() {
  var path = "/business/supplier/list";
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function getManufacturerData() {
  var path = "/business/manufacturer/list";
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function getPositionData() {
  var path = "/business/position/list";
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function getCategoryData() {
  var path = "/business/category/list";
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function getDictionaryData(category) {
  var path = "/business/dictionary/queryList?category="+category;
  return Vue.$http.get(path)
    .then((res) => {
        return res.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



export  function insertDevice(insertForm) {
  var path = "/business/device/insert";
  return Vue.$http.post(path, {
    serialNumber: insertForm.deviceNum,
    name: insertForm.name,
    positionId: insertForm.possition,
    positionIds: insertForm.possitionIds,
    state: insertForm.state,
    categoryId: insertForm.categoryId,
    categoryIds: insertForm.categoryIds,
    deviceFunction: insertForm.function,
    costCenter: insertForm.DCCValue,
    criticalLevel: insertForm.criticalLevelValue,
    supplierId: insertForm.supplierId,
    manufacturerId: insertForm.manufacturerId,
    model: insertForm.model,
    replaceableNumber: insertForm.replaceableNum
    })
    .then((res) => {
        return res;
    })
    .catch(function (error) {
      console.error(error);
    });
  }


export  function updateDevice(insertForm) {
  var path = "/business/device/update";
  return Vue.$http.post(path, {

    id: insertForm.id,
    serialNumber: insertForm.deviceNum,
    name: insertForm.name,
    positionId: insertForm.possition,
    positionIds: insertForm.possitionIds,
    state: insertForm.state,
    categoryId: insertForm.categoryId,
    categoryIds: insertForm.categoryIds,
    deviceFunction: insertForm.function,
    costCenter: insertForm.DCCValue,
    criticalLevel: insertForm.criticalLevelValue,
    supplierId: insertForm.supplierId,
    manufacturerId: insertForm.manufacturerId,
    model: insertForm.model,
    replaceableNumber: insertForm.replaceableNum
    })
    .then((res) => {
        return res;
    })
    .catch(function (error) {
      console.error(error);
    });
  }
  
  
  export  function deleteDevice(deviceId) {
    var path = "/business/device/deleteById?deviceId="+deviceId;
    return Vue.$http.get(path)
    .then((res) => {
      return res.data;
    })
    .catch(function (error) {
      console.error(error);
    });
  }
  
  
  
  
  export  function getDeviceInfoById(deviceId) {
    var path = "/business/device/getDeviceInfo?deviceId="+deviceId;
    return Vue.$http.get(path)
      .then((res) => {
          return res.data.data;
      })
      .catch(function (error) {
        console.error(error);
      });
  }


export  function getDeviceList(serialNumber, name, pageNum ,pageSize) {
  var path = "/business/device/getList";
  return Vue.$http.post(path, {
      serialNumber: serialNumber,
      name: name,
      pageNum: pageNum==null?0:pageNum,
      pageSize: pageSize==null?10:pageSize
    })
    .then((res) => {
        return res.data.data.data;
    })
    .catch(function (error) {
      console.error(error);
    });
}



